/******************************************************/
/* Goblin's Cube - Rubik's cube game for Wii Homebrew */
/* Copyright (C) 2009 Ricardo Bueno Cordeiro          */
/* Licensed under de GNU General Public License v2.0  */
/*   See license_gplv2.txt for detalis                */
/******************************************************/

#ifndef __SOUND_WAVE_LOADER_H_
#define __SOUND_WAVE_LOADER_H_

#include <gccore.h>

#include "sound.h"

struct riff_file_t {
	u32 riff;
	u32 total_size;
} __attribute__ ((packed));

struct wave_header_t {
	u32 wave;
} __attribute__ ((packed));

struct wave_block_header_t {
	u32 block;
	u32 size;
} __attribute__ ((packed));

struct wave_fmt_block_t {
	struct wave_block_header_t header;
	u16 compression;
	u16 num_channel;
	u32 sample_rate;
	u32 average;
	u16 block_align;
	u16 significant_bits;
	u16 extra_size;
	u16 extra_data;
} __attribute__ ((packed));

struct wave_data_block_t {
	struct wave_block_header_t header;
	u32 samples;
} __attribute__ ((packed));

class SoundWaveLoader : public SoundLoader {
	private:
	struct wave_fmt_block_t *fmt;
	struct wave_data_block_t *data;
	
	public:
	SoundWaveLoader(const u8 *file, u32 size);
	
	u32 get_size();
	s32 get_pitch();
	u16 get_num_bits_per_sample();
	u16 get_num_channel();
	void get_samples(void *buffer, u32 start, u32 size);
};

#endif
